home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!news
- From: philma@ix.netcom.com(Phil Majtan)
- Newsgroups: comp.lang.c
- Subject: Re: A real basic problem?: (code!) long integers or compiler problem?
- Date: 20 Apr 1996 22:10:05 GMT
- Organization: Netcom
- Message-ID: <4lbnbt$9r2@dfw-ixnews5.ix.netcom.com>
- References: <4l3mom$f26@newsbf02.news.aol.com> <4l699u$cgo@newsbf02.news.aol.com>
- NNTP-Posting-Host: det-mi4-10.ix.netcom.com
- X-NETCOM-Date: Sat Apr 20 5:10:05 PM CDT 1996
-
- In <4l699u$cgo@newsbf02.news.aol.com> theoder@aol.com (The Oder)
- writes:
- >
- >Repost of original problem: (code to follow)
- >
- >I'm in the process of relearning C and have been doing some beginning
- >programs on my PC. I have two compilers (Borland C++ and Power C).
- My
- >problem is that when I run a program using "long" integers (i.e.
- declare a
- >variable as "long"), it locks up immediately and I have to reboot.
- This
- >has happened with both compilers and with two different really basic
- >programs (i.e. just trying to do a loop that will compute the first 10
- >powers of 2, and another one that simply just tries to find the
- largest
- >positive long value on my computer--> I can find the largest positive
- int
- >value, but when I convert it to long, it locks up)
- >
- >Is this a problem I have with BOTH (?!?!) compilers, is it my computer
- >(486-DX2, 8 megs RAM) or settings, or is it just something I haven't
- >learned yet about long integers? One of these programs I copied
- directly
- >from one of TWO books I'm using and it just locks up!
- >
-
- I tried the code you enclosed and it ran fine, albeit REALLY slowly.
- If you strip out the printf and let it run for a couple of hours
- (really), it will finish. The problem is that a long int is good up to
- 2,147,483,648. That takes a while to count up to.
- Enjoy,
- Phil
-
-